const mobileValidator = async (rule, value) => {
  if (!value) {
    return Promise.reject('请输入手机号')
  } else if (!/^1[3456789]\d{9}$/.test(value)) {
    return Promise.reject('手机格式不正确，请重新输入')
  } else {
    return Promise.resolve()
  }
}

/* 通用表单 */
export const FORM_CONFIG = [
  {
    type: 'input',
    prop: 'name',
    label: '姓名',
    defaultValue: '就是这么嚣张',
    required: true,
    disabled: false,
    col: 12,
    attrs: {
      placeholder: '请输入'
    }
  },
  {
    type: 'input',
    prop: 'phone',
    label: '电话',
    rule: [
      {
        required: true,
        message: 'Please input email address',
        trigger: 'blur'
      },
      {
        type: 'email',
        message: 'Please input correct email address',
        trigger: ['blur', 'change']
      }
    ],
    col: 12,
    attrs: {
      placeholder: '请输入电话'
    }
  },
  {
    type: 'input',
    prop: 'content',
    label: '备注',
    disabled: true,
    defaultValue: '这是一段小备注'
  },
  {
    type: 'select',
    prop: 'sex',
    label: '性别',
    required: true,
    options: [
      { label: '女', value: '0' },
      { label: '男', value: '1' }
    ]
  },
  {
    type: 'select',
    prop: 'hobby',
    label: '爱好',
    required: true,
    isShow: (item, data) => data.sex == 1,
    attrs: {
      allowClear: true,
      style: {
        width: '170px'
      }
    },
    options: [
      { label: '篮球', value: '篮球' },
      { label: '足球', value: '足球' }
    ]
  },
  {
    type: 'select',
    prop: 'like',
    label: '兴趣',
    required: true,
    isShow: (item, data) => data.hobby == '足球',
    options: [
      { label: '唱', value: '0' },
      { label: '跳', value: '1' },
      { label: 'rap', value: '2' }
    ],
    attrs: {
      allowClear: true,
      style: {
        width: '170px'
      }
    }
  },
  {
    type: 'date-picker',
    prop: 'birthday',
    label: '生日',
    required: true
  },
  {
    type: 'date-picker',
    prop: 'curriculum',
    label: '活动时间',
    required: true,
    attrs: {
      'start-placeholder': 'Start month',
      'end-placeholder': 'End month',
      type: 'yearrange'
    }
  }
  // {
  //   type: 'slot',
  //   slotName: 'content',
  //   key: 'slot',
  //   label: ' 超操一个'
  // }
]
